package com.glela.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.glela.redis.service.LoadCacheDataService;

@Controller("RedisController")
@RequestMapping(value = "/redisReload")
public class RedisController
{
	private static Logger logger = LoggerFactory.getLogger(RedisController.class);
 	@Resource
	LoadCacheDataService service;

	@RequestMapping(value = "/load", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public String index(HttpServletRequest request, HttpServletResponse response)  
	{
 		logger.debug("redis update start");
		service.reloadData();
		logger.debug("redis update end");
 		return "redis update done";
	}
 
	@RequestMapping(value = "/loadVideo", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public String loadVideoData(HttpServletRequest request, HttpServletResponse response)  
	{
 		logger.debug("redis update Video start");
		service.reloadVideoData();
		logger.debug("redis update Video end");
 		return "redis update Video done";
	}
}
